// town script for town 9: Controls level


begintownscript;

variables;

int choice;

body;

beginstate INIT_STATE;

	if (get_flag(9,3) == 1)
			set_terrain(9,4,384);
					
	if (get_flag(9,3) == 0)
			set_terrain(9,4,388);

break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
if (get_flag(9,0) == 1) {
		message_dialog("This is a large control panel. All kinds of lamps have started blinking. Its pretty. You get a bit sleepy seeing all those lovely green, blue and red lights turning on and off.","");
		set_state_continue(12);
		end();
		}
	message_dialog("The control panel is dead. No lights are on. Everything is stuffy and crumbling.","You turn away from it. The sight of the old panel starts depressing you.");
break;

beginstate 11;
	reset_dialog();
	add_dialog_str(0,"A big lever stands here. It is old and rusty. You could try to pull it.",0);
	add_dialog_choice(0,"Leave it.");
	add_dialog_choice(1,"Pull it.");
	choice = run_dialog(0);
	if (choice == 2) {
	
			if (get_flag(9,3) == 0) {
					message_dialog("You pull the lever. Suddenly the room is filled with lovely lamps. You switched the power on.","");
					flip_terrain(8,13);
					set_flag(9,0,1);
					set_flag(9,3,1);
					set_terrain(9,4,384);
					end();
					}
					
			if (get_flag(9,3) == 1) {
					message_dialog("You pull the lever. The room gets dark again. You never imagined that just one control panel could shed so much beautiful light.","");
					flip_terrain(8,13);
					set_flag(9,0,0);
					set_flag(9,3,0);
					set_terrain(9,4,388);
					end();
					}
			}
break;

beginstate 12;
reset_dialog();
	add_dialog_str(0,"In the middle of the control panel a small button has been placed, saying: _beam generator power ON/OFF_.",0);
	add_dialog_str(0,"You can say a lot of things about this button, but its certainly a nice button to press. Do you?",0);
	add_dialog_choice(0,"leave it.");
	add_dialog_choice(1,"Press it.");
	choice = run_dialog(0);
	
	if (choice == 1)
			end();
	
	if (choice == 2)
		if (get_flag(8,6) == 0) {
				message_dialog("You press the button. You hear a hum. Then the hum stops, and the halls above you become amazingly quiet.","");
				set_flag(8,6,1);
				run_animation_sound(90);
				end();
				}
			message_dialog("When you press the button, the silence stops and the normal hum starts again.","");
			set_flag(8,6,0);
			run_animation_sound(90);
break;

beginstate 13;
	move_to_new_town(8,22,24);
break;

beginstate 14;
	reset_dialog();
	add_dialog_str(0,"This control panel doesn't function anymore. Even with the power off you can see that. A large black hole dominates the control panel.",0);
	add_dialog_str(1,"It probably exploded some day earlier. One knob description is still readable: _creation chambers power ON/OFF_.",0);
	add_dialog_str(2,"After studying this panel for a while, you go away. That hole is starting to bore you.",0);
	add_dialog_choice(0,"Okay");
	choice = run_dialog(1);
break;

beginstate 15;
if (get_flag(9,1) == 1)
		end();
	message_dialog("This room still looks quite used, although the dust contradicts this. On a heightening, you see two chairs standing. Strange this level wasn't visited by the monsters you saw on the main level of this place.","");
	set_flag(9,1,1);
break;

beginstate 16;
if (get_flag(9,2) == 1)
		end();
	message_dialog("Once you stand on the stairs, you see two control panels and a lever. You also see some descriptions of them behind them on the wall.","");
	set_flag(9,2,1);
break;